package dailytest;

/**
 * @Author: heweiwei
 * @Date: 11/19/24 PM5:19
 * @Description:
 */
public class StrTest {

    public static void main(String[] args) {
        //parseStr("1@1@111901;111902;111903;111904;111905");
        parseStr("1@1@111901,111902,111903,111904,111905");

    }

    private static String parseStr(String sendMedicationNo) {
        //如果包含@
        if (sendMedicationNo.contains("@")) {
            // 找到最后一个 "@" 符号的位置
            int lastAtIndex = sendMedicationNo.lastIndexOf('@');
            // 截取所需要的字符串，从第二个 "@" 后到第二个 "@" 之前
            String anyPlanId = sendMedicationNo.substring(lastAtIndex + 1);
            System.out.println("anyPlanId = " + anyPlanId);
            //如果包含;
            String[] split1 = anyPlanId.split(";");
            if (split1.length > 1) {
                System.out.println("字符串包含[;]," + split1[0]);
                return split1[0];
            }
            String[] split = anyPlanId.split(",");
            if (split.length > 1) {
                System.out.println("字符串包含[,]," + split[0]);
                return split[0];
            }
        }
        return sendMedicationNo;
    }
}
